﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace _21.CountDifferentWordsInText
{
    class CountDifferentWordsInText
    {
        static void Main(string[] args)
        {
            string sentence = "C# is not C++, not PHP and not Delphi!PHP is not C++.";
            Console.WriteLine(sentence);
            string[] words = sentence.Split(new char[] { ' ', ',', '.', '!', '?' }, StringSplitOptions.RemoveEmptyEntries);
            Dictionary<string, int> dictionary = new Dictionary<string, int>();
            foreach (var word in words)
            {
                if (dictionary.ContainsKey(word))
                {
                    dictionary[word] = dictionary[word] + 1;
                }
                else 
                {
                    dictionary.Add(word, 1);
                }
            }

            foreach (var word in dictionary)
            {
                Console.Write("{0}-{1,-5}", word.Key, word.Value);
            }
            Console.WriteLine();
        }
    }
}
